Skip to content

Fix a bad dataState value when an error occurs on a deferred field that bubbles to the defer boundary - #13376

Open
jerelmiller wants to merge 2 commits into
release-4.3from
jerel/fix-data-state-streaming-error
Open

Fix a bad dataState value when an error occurs on a deferred field that bubbles to the defer boundary#13376
jerelmiller wants to merge 2 commits into
release-4.3from
jerel/fix-data-state-streaming-error

Conversation

@jerelmiller

@jerelmiller jerelmiller commented Jul 31, 2026

Copy link
Copy Markdown
Member

While working on an experiment for an unrelated issue, I stumbled upon this behavior. Currently an error reported by a @defer field that bubbles to the defer boundary reports the final chunk to the user as complete instead of streaming even though the result still has the hole in the data. This fix unconditionally applies the diff data to result when the dataState is streaming rather than only applying to when hasNext is true. This makes sure the final chunk delivers the right dataState value.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed @defer queries incorrectly reporting a complete state when deferred-field errors occur.
    • Streaming results now remain marked as streaming while additional data may still arrive.
    • Streamed data and associated errors are preserved correctly in the final payload.

@jerelmiller
jerelmiller requested a review from phryneas July 31, 2026 22:02
@apollo-librarian

apollo-librarian Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 1 changed, 0 removed
* (developer-tools)/react/(latest)/data/fragments.mdx

Build ID: 22d78122423c4ea713325a69
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/22d78122423c4ea713325a69


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f0431c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c1ef014c-ba49-4d1b-8205-3ba1a85092eb

📥 Commits

Reviewing files that changed from the base of the PR and between 48f7386 and f0431c5.

📒 Files selected for processing (3)
  • .changeset/loud-bulldogs-pay.md
  • src/core/QueryInfo.ts
  • src/incremental/handlers/__tests__/graphql17Alpha9/defer.test.ts

📝 Walkthrough

Walkthrough

The change preserves dataState: "streaming" for @defer results when deferred-field errors reach the defer boundary. QueryInfo accepts streaming cache diffs without requiring hasNext, and the defer test expectations now cover streamed data, errors, and partial results.

Changes

Deferred streaming state

Layer / File(s) Summary
Preserve streaming state through cache results and tests
src/core/QueryInfo.ts, src/incremental/handlers/__tests__/graphql17Alpha9/defer.test.ts, .changeset/loud-bulldogs-pay.md
QueryInfo accepts streaming cache diffs without requiring hasNext. The defer test keeps the final result streaming with NetworkStatus.error and partial: true. A patch changeset documents the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: auto-cleanup

Suggested reviewers: phryneas, daleseo

Poem

A rabbit watched the payload flow,
“Keep streaming,” said the data below.
Errors reached the defer gate,
But completion had to wait.
Tests now guard the proper state—
Hop, hop, fixed at last!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix for the incorrect dataState value caused by errors on deferred fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/core/QueryInfo.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/incremental/handlers/__tests__/graphql17Alpha9/defer.test.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 31, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@apollo/client@13376

commit: f0431c5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant